package no.uib.kwikktaim.gui.actionlisteners;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import no.uib.kwikktaim.gui.MainWindow;

/**
 * Maximize and minimize the playlist in mainwindow;
 */
public class MinimizeMaximizePlaylist implements ActionListener {

	private boolean maximized = false;
	private MainWindow mw;

	public MinimizeMaximizePlaylist(MainWindow mw) {
		this.mw = mw;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		mw.listScroller.setVisible(maximized);

		// Hack
		if(maximized) {
			mw.setSize(new Dimension(mw.getWidth(),mw.getHeight()+mw.listScroller.getHeight()));
			mw.buttonPlaylistMinimize.setText("Hide Playlist");
		}
		else {
			mw.setSize(new Dimension(mw.getWidth(),mw.getHeight()-mw.listScroller.getHeight()));
			mw.buttonPlaylistMinimize.setText("Show Playlist");
		}

		maximized = !maximized;
	}

}
